package com.spring.mvc.web_demo.controller;

import com.spring.mvc.annotation.IAutowired;
import com.spring.mvc.annotation.IController;
import com.spring.mvc.annotation.IRequestMapping;
import com.spring.mvc.annotation.IRequestParam;
import com.spring.mvc.web_demo.service.DemoService;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Author: WuPeng
 * @Date: 2021/6/5 2:33 下午
 */
@IController
@IRequestMapping("demo")
public class DemoController {
    @IAutowired
    private DemoService demoService;

    @IRequestMapping("test")
    public void test(@IRequestParam("name") String name,
                     HttpServletRequest request,
                     HttpServletResponse response){
        String res = demoService.sayHello(name);
        try {
            response.getWriter().write(res);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
